import numpy as np


def find_closest_trend(target_sequence, data_sequences):
    # 将目标序列转换为numpy数组
    target = np.array(target_sequence)

    # 初始化最小距离为无穷大，最接近的序列为None
    min_distance = float('inf')
    closest_sequence = None

    # 遍历所有数据序列
    for sequence in data_sequences:
        # 将当前序列转换为numpy数组
        current = np.array(sequence)

        # 计算当前序列与目标序列的欧氏距离
        distance = np.linalg.norm(current - target)

        # 如果当前距离小于最小距离，则更新最小距离和最接近的序列
        if distance < min_distance:
            min_distance = distance
            closest_sequence = sequence

    # 返回与目标序列变化趋势最接近的序列
    return closest_sequence


# 示例数据
target_sequence = [4.25, 4.25, 1.52, 2.15, 3.85, 2.47]
data_sequences = [
    [4.26, 4.24, 1.53, 2.14, 3.84, 2.46],
    [4.24, 4.26, 1.51, 2.16, 3.86, 2.48],
    [4.15, 4.35, 1.42, 2.25, 3.95, 2.57],
    [4.35, 4.15, 1.62, 2.05, 3.75, 2.37]
]

# 调用函数
closest_sequence = find_closest_trend(target_sequence, data_sequences)
print("最接近的序列:", closest_sequence)